/**
 * Created by larry.quns on 2022/4/7.
 */
var ai = 1;

function startMeiTuanOrder() {
    logd("开始抢菜")
    if (findNode(textMatch("结算"), true)) {
        sleep(random(5, 25));
    }
    if (findNode(textMatch("立即支付"), true) || findNode(textMatch("极速支付"), true)) {
        lijizhifu();
    }
    if (findNode(textMatch("支付成功"), false)) {
        return
    }
    if (findNode(textMatch("我知道了"), true) || findNode(textMatch("返回购物车"), true)) {
        sleep(random(10, 25));
        ai = ai + 1;
        if (ai % 5 === 1) {
            //下拉刷新
            rndSwipe(500, 540, 505, 900, 30, 100, 300);
            sleep(random(800, 1200));
        }
    }
    startMeiTuanOrder();
}

function lijizhifu() {
    if (findNode(textMatch("立即支付"), true) || findNode(textMatch("极速支付"), true)) {
        sleep(random(10, 25));
    }
    if (findNode(textMatch("支付成功"), false)) {
        return
    }
    if (findNode(textMatch("我知道了"), true)) {
        sleep(random(10, 25));
        ai = ai + 1;
        if (ai % 8 === 1) {
            //下拉刷新
            rndSwipe(500, 540, 505, 900, 30, 100, 300);
            sleep(random(800, 1200));
        }
    }
    if (findNode(textMatch("结算"), true)) {
        startMeiTuanOrder();
    }
    lijizhifu();
}